package com.example.love_margin.Mapper.Until;

import com.example.love_margin.Entity.Until.Img;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ImgMapper {

    @Insert("INSERT INTO img(url,state)values(#{url},#{state})")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    int addImg(Img img);


    //单张删除
    @Delete("DELETE FROM test WHERE url=#{url}")
    int delete(String url);

    //全部删除
    @Delete("DELETE FROM img")
    int deleteAll();

    //通过url查询
    @Select("SELECT url FROM img")
    List<String> select();

    //通过url查询
    @Select("SELECT url FROM img WHERE url = #{url}")
    int selectUrl(String url);

    //通过state状态码查询
    @Select("SELECT url FROM img WHERE state = 'unsuccessful'")
    List<String> selectPetOldUrl();

    //通url修改状态码
    @Select("UPDATE img SET state = 'success' WHERE url = #{oldUrl}")
    void upPetOldUrl(@Param("oldUrl") String oldUrl);

}
